#!/usr/bin/node
const log = console.log;
let buf1 = new Buffer(256);
buf1[0] = 0;
log(buf1.length);
//256
log(buf1);
//初始化buf1中的每个字节
for(let i = 0; i < buf1.length; i++) {
  buf1[i] = i;
}
log(buf1);

var buf2 = buf1.slice(250,256);
log(buf2);
//buf2.fill(0);
log(buf2);
log(buf2.length);
//buf2.toJSON
log(buf2.toJSON());

let arr = ['a',0xba, 255, 10 ];
let buf3 = new Buffer(arr);
log(buf3);
log(buf3.length);

let str= 'hello world';
var buf4 = new Buffer(str, 'utf8');
log(buf4);
log(buf4.length);

buf4.copy(buf3,0,0,buf3.length);
log(buf3);
log(buf4);

